package com.expense.app.admin.controller;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
import com.expense.common.util.Result;
import com.expense.app.admin.services.LogsServ;
import com.expense.app.admin.model.params.logs.LogsParam;
import com.expense.app.admin.model.params.logs.LogsListParam;

/*
*
* gen controller 2019-09-06
*/
@Validated
@RestController
@RequestMapping("/logs")
public class LogsCtrl {

    @Autowired
    LogsServ logsServ;

    @GetMapping("")
    public Result findList(@Validated LogsListParam param) {
        return Result.success(logsServ.findList(param));
    }

    @GetMapping(value = "/{id}")
    public Result findDetail (@PathVariable @Min(1) Long id) {
        return Result.success(logsServ.findDetail(id));
    }

    @PostMapping(value = "")
    public Result saveOne(@Validated @RequestBody LogsParam param) {
        return Result.success(logsServ.saveOne(param));
    }

    @PutMapping(value = "")
    public Result update(@Validated @RequestBody LogsParam param) {
        return Result.success(logsServ.saveOne(param));
    }

    @DeleteMapping(value = "/{id}")
    public Result deleteOne(@PathVariable @Min(1) Long id) {
        return Result.success(logsServ.deleteOne(id));
    }
}
